package com.bootdo.system.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.bootdo.system.dao.TUserDao;
import com.bootdo.system.domain.TUserDO;
import com.bootdo.system.service.TUserService;



@Service
public class TUserServiceImpl implements TUserService {
	@Autowired
	private TUserDao tUserDao;
	
	@Override
	public TUserDO get(Integer id){
		return tUserDao.get(id);
	}
	
	@Override
	public List<TUserDO> list(Map<String, Object> map){
		return tUserDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return tUserDao.count(map);
	}
	
	@Override
	public int save(TUserDO tUser){
		return tUserDao.save(tUser);
	}
	
	@Override
	public int update(TUserDO tUser){
		return tUserDao.update(tUser);
	}
	
	@Override
	public int remove(Integer id){
		return tUserDao.remove(id);
	}
	
	@Override
	public int batchRemove(Integer[] ids){
		return tUserDao.batchRemove(ids);
	}

	@Override
	public int verify(Integer id) {
		int res = 0;
		TUserDO tUserDO = tUserDao.get(id);
		if (null!=tUserDO){
			TUserDO updateDo = new TUserDO();
			updateDo.setId(id);
			updateDo.setUpdatedTime(new Date());
			if (tUserDO.getIsValid()){
				updateDo.setIsValid(false);
			}else {
				updateDo.setIsValid(true);
			}
			res = tUserDao.update(updateDo);
		}

		return res;
	}

}
